package com.fanhang.samples.springboot.data.jpa.web;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.util.Assert;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.fanhang.samples.springboot.data.jpa.domain.Country;
import com.fanhang.samples.springboot.data.jpa.service.CountryRepository;

@Controller
@RequestMapping("/country")
public class CountryController {
	
	@Autowired
	private CountryRepository repository;
	
	@ResponseBody
	@RequestMapping("/get")
	public Country get(@RequestParam(value="id") Integer id) {
		Assert.notNull(id);
		return repository.findOne(id);
	}
	
}
